package com.ee.pet.config;


import com.ee.pet.filter.LoginInterceptorImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class Webconfig extends WebMvcConfigurationSupport {
    @Autowired
    LoginInterceptorImpl loginInterceptor;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 将物理路径 /data/uploads 映射为 URL路径 /img/**
        registry.addResourceHandler("/blogs/**")
                .addResourceLocations("file:/home/pet_img/blogs/");
    }
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        super.addInterceptors(registry);
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/users/elogin")
                .excludePathPatterns("/users/sendcode")
                .excludePathPatterns("/users/plogin")
                .excludePathPatterns("/users/register");
//                .excludePathPatterns("/imserver/**");
//
    }
}
